<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .div1{
        width: 200px;
        height: 200px;
        background-color: green;
    }
    .div1 .inner-box{
        width: 20%;
        height: 20%;
        background-color: pink;
    }
</style>
<body>
    <div class="div1">
        <div class="inner-box"></div>
    </div>
    <button class="btn" onclick="clone(this)">添加</button>
    <script>
        function clone(btn) {
            // var btn = document.querySelector('.btn');
            var div1 = document.querySelector('.div1');
            // 传参true，深度克隆，内部元素也克隆
            var newNode = div1.cloneNode(true);
            document.body.insertBefore(newNode, btn);
        }
    </script>
</body>
</html>